export default {
	name: 'spec',
	data () {
		return {
			specList: [],// 规格列表
		}
	},
	// 定义传入的参数
	props: {
	},
	methods: {
		getData (e = []) {
			this.specList = e
		},
		// 添加规格
		addSpec () {
			this.specList.push({
				spec_name: "",// 规格名称
				spec_image: "",// 规格土坯那
				supplier_product_number: "",// 供应商编码
				supplier_product: "",// 供应商名称
				cost_price: "",// 成本价
				system_cost_price: "",// 系统成本价
				price: "",// 售价
				stock: "",// 库存
				status: 1,// 状态 1-上架 2-下级 
			})
			this.peration()
		},
		// 删除规格
		delSpec (index) {
			// 从提交的数据中删除
			this.specList.splice(index, 1)
			this.peration()
		},
		// 添加抵扣
		addDiscount (index) {
			this.specList[index].discountList.push({
				number: '',
				price: '',
			})
			this.peration()
		},
		// 删除规格折扣
		delSpecDiscount (index, index2) {
			// 从提交的数据中删除
			this.specList[index].discountList.splice(index2, 1)
			this.peration()
		},
		// 规格文件选择
		specFileConfirm (e) {
			this.specList[e.name].spec_image = e.fileList.toString(',')
			this.peration()
		},
		// 清除数据
		clear () {
			this.specList = []
			this.peration()
		},
		// 操作
		peration () {
			this.$emit('specOperation', this.specList)
		},
	}
}